using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using ExtendedMvc.Elements;

namespace ExtendedMvc {
	public static class HtmlGridExtensions {

		public static Grid<T> Grid<T>(this ModelViewHtmlHelper<IEnumerable<T>> html, Expression<Func<T, object>> keySelector, object options = null) where T : class {
			return new Grid<T>(html, keySelector, options);
		}

		public static Grid<T> Grid<T>(this ModelViewHtmlHelper<IEnumerable<T>> html, string keyName, object options = null) where T : class {
			return new Grid<T>(html, (m) => typeof(T).GetProperty(keyName).GetValue(m, null), options);
		}
	}
}
